package com.activemq.demo.activemq_service.service;

import jakarta.jms.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Service;

@Service
public class DeadMessageConsumerService {
    private static final Logger logger = LoggerFactory.getLogger(DeadMessageConsumerService.class);

    @JmsListener(destination = "DLQ.message.queue")
    public void receiveDeadLetter(String messageContent,
                                  @Header(name = "messageId", required = false) String messageId,
                                  Message message) {
        logger.error("⚠️ 死信队列收到消息：" + messageId);
    }
}
